#!/usr/bin/env node

const Radio = require('./04-radio')
const station = {
    freq: '106.7',
    name: 'music radio'
}
  

// 实例化 Radio 对象
const radio = new Radio(station)

// 处理 play 事件
radio.on('play', station => {
    console.log(`${station.name} FM ${station.freq} opened`)
    console.log(`Now playing on ${station.name} at frequency${station.freq}.`)
})

// radio.on('play', station => {
//     console.log(`hello: ${JSON.stringify(station)}`)
//     console.log(`eventNames: ${radio.eventNames()}`)
//     console.log(`play listener count: ${radio.listenerCount('play')}`)
//     console.log(`play listeners: ${radio.listeners('play')}`)
//   })
  


// 处理 stop 事件
radio.on('stop', station => {
    console.log(`${station.name} FM ${station.freq} closed`)
    console.log(`Stopped playing on ${station.name} at frequency${station.freq}.`)
})